<template>
  <common_print_dialog ref="common_print_dialog" businessType="EXPRESS_WAYBILL" v-bind="$attrs" v-on="$listeners"
    :tableModel="models" :printUrl="printUrl" :printHandler="printHandler" :previewUrl="previewUrl"
    :previewHandler="previewHandler" :previewMergeUrl="previewMergeUrl" :previewMergeHandler="previewMergeHandler" :printClientParam="printClientParam" printClientUrl="/print-api/template/PrintTemplateCfgRpc/getOnlineClientInServerOutlet.json"/>
</template>

<script>
import common_print_dialog from './common_print_dialog.vue'
import role_system_mixin from '@/mixin/role_system_mixin';

export default {
  mixins: [role_system_mixin,],
  components: { common_print_dialog },
  data() {
    return {
      printUrl: null,
      previewUrl: null,
      previewMergeUrl: null,
      models: [
      { key: 'changeTrackNumberBefore', label: 'label_transit_face_before', 'min-width': 160, 'show-overflow-tooltip': true, },
          { key: 'changeTrackNumberAfter', label: 'label_transit_face', 'min-width': 160, 'show-overflow-tooltip': true, },
          { key: 'customerName', label: 'label_customer_name', 'min-width': 120, 'show-overflow-tooltip': true },
          { key: 'auCarrierName', label: 'label_carrier', 'min-width': 120, 'show-overflow-tooltip': true },
          { key: 'destinationPlaceName', label: 'label_next_station', 'min-width': 120, 'show-overflow-tooltip': true },
          { key: 'transportType', label: 'label_logistics_methods', 'min-width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$enumShow(v, "LogisticsProductsTypeEnum") },
      ]
    }
  },
  props: {

    basePrint: false,
    printClientParam: {
      type: Object,
      default: ()=>{},
    },
  },
  created() {
    this.printUrl = "/tms-api/waybill/TmsExpressPrintRpc/printByWaybill.json"
    this.previewUrl = "/tms-api/waybill/TmsExpressPrintRpc/previewWaybill.json"
    // this.previewMergeUrl = "/wms-api/inbound/WmsInboundOverseasInboundOrderRpc/mergeBox.json"

  },
  methods: {


    printHandler(data, rows) {
      data.waybillIds = rows.map(row => row.id)
      data.clientId = `${rows[0].placeId}_${data.clientId}`
      data.printNum = data.printNumSum
      return data
    },
    previewHandler(data, row) {
      data.waybillId = row.id
      data.printNum = data.printNumSum
      return data
    },
    previewMergeHandler(data, rows) {

      return data
    },
    printDefaultOption(data){
      this.$refs.common_print_dialog.printDefaultOption(data)
    },
    show(rows,option) {
      this.$refs.common_print_dialog.show(rows,option)
    }
  }
}
</script>
